package swings.mycomponent.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * @Title: JStatusBar.java
 * @Description: TODO(自定义状态栏)
 * @author H819
 * @date 2010-10-10
 * @version V1.0
 */
public class JStatusBarPanel extends JPanel {

	public JStatusBarPanel(String leftStatusInfo, String rightStatusInfo) {
		setLayout(new BorderLayout());
		setPreferredSize(new Dimension(10, 23));

		JPanel rightPanel = new JPanel(new BorderLayout());
		rightPanel.setOpaque(false);
		JLabel statusLeft = new JLabel(leftStatusInfo);
		JLabel statusRight = new JLabel(rightStatusInfo);
		add(statusLeft, BorderLayout.WEST);
		add(statusRight, BorderLayout.EAST);
	}

	protected void paintComponent(Graphics g) {
		super.paintComponent(g);

		int y = 0;
		g.setColor(new Color(156, 154, 140));
		g.drawLine(0, y, getWidth(), y);
		y++;
		g.setColor(new Color(196, 194, 183));
		g.drawLine(0, y, getWidth(), y);
	}

	// 测试
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setSize(600, 200);

		Container contentPane = frame.getContentPane();
		contentPane.setLayout(new BorderLayout());

		JStatusBarPanel statusBar = new JStatusBarPanel("你好", "谢谢");
		contentPane.add(statusBar, BorderLayout.SOUTH);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);

	}
}
